package com.effects;

import static com.effects.BasicEffect.rainbow;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;

/**
 * @author sad
 */
public class MovedFrequencyEffect extends BasicEffect{

    @Override
    public String getEffectName() {
        return "MoveFrequency";
    }

    @Override
    public String getId() {
        return "mf";
    }
    
     @Override
    public BufferedImage getImage(byte[] pcm) {
        spectrum(pcm);
        alphaClearingImage(image,10);
        Graphics g=image.getGraphics();
        g.drawImage(image, 0, -1,image.getWidth()/2,image.getHeight()-1,1,0,image.getWidth()/2+1,image.getHeight(), null);
        g.drawImage(image, image.getWidth()/2+1,-1,image.getWidth()+1,image.getHeight()-1,image.getWidth()/2,0,image.getWidth(),image.getHeight(), null);
        
        g.dispose();
        
        g = image.getGraphics();
        g.setColor(Color.black);
        g.setColor(Color.green);
        int height = image.getHeight();
        spectrum[0]/=5;
        for (int i = 0; i < spectrum.length; i++) {
            g.setColor(rainbow[i%rainbow.length]);
            double r = spectrum[i];
            double nr = (r * 34);
            spectrum[i] = nr;
            g.drawLine(i, height - (int) nr, i, height);
        }

        return image;
    }

}
